package com.ruoyi.wapp.controller;

import com.ruoyi.common.constant.CacheKeyConstants;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.WdyBanner;
import com.ruoyi.system.service.IWdyBannerService;
import com.ruoyi.wapp.controller.base.BaseController;
import com.ruoyi.wapp.controller.base.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class IndexController extends BaseController {

    @GetMapping("/")
    public Result index() {
        return Result.ok().put("data", DateUtils.getTime());
    }

    @GetMapping("/getBanners")
    public Result getBanners(Integer bannerType) {
        String cacheKey = CacheKeyConstants.getTempletString(CacheKeyConstants.BANNER, String.valueOf(bannerType));
        List<WdyBanner> list = (List<WdyBanner>) redisTemplate.opsForValue().get(cacheKey);
        return Result.ok().put("list", list);
    }

}
